function doSearch(){    
    $('#tt').datagrid('load', {    
    	mark: $('#mark').val(),
    	channelName: $('#channelName').val(),
    	apkName: $('#apkName').val()
    });
}

function add(){
    showMyWindow('模拟配置管理 |模拟新增配置管理', '/channelapk/addConfig', 800, 500);
}

function edit(){
	var row = $('#tt').datagrid('getSelected');
	var mark = row.mark;
    if (row){
	    showMyWindow('模拟器配置管理 | 编辑模拟器配置', '/channelapk/'+mark+'/configUpdate', 700, 500);
    } else {
    	showMsg(market.content.title, market.content.tips, alert);
    }
}

function del(){
	var row = $('#tt').datagrid('getSelected');
	var mark = row.mark;
    $.messager.confirm('温馨提醒','你确定删除本条数据吗？',function(r){
        if(r){
            $.get('/channelapk/delete?mark='+mark,function(data){
                if (data.return_code == '1') {
					top.showMsg(market.content.title, data.return_msg, alert);
					doSearch();
				}else if(data.return_code == '3'){
					top.showMsg(market.content.title, data.return_msg, alert);
				} else {
					$.messager.alert(market.content.title, data.return_msg);
				}
            });
        }
    });
}

function formatterModel(value,row,index){
	 var a = '<a href="#" onclick="editModel('+"'"+row.mark+"'"+')">配置</a> ';
	 return a;
}

function formatterRetent(value,row,index){
	 var a = '<a href="#" onclick="editRetent('+"'"+row.mark+"'"+')">配置</a> ';
	 return a;
}

function formatterProvince(value,row,index){
	 var a = '<a href="#" onclick="editProvince('+"'"+row.mark+"'"+')">配置</a> ';
	 return a;
}

function editModel(mark){
	showMyWindow('模拟器配置| 编辑曲线配置', '/channelapk/' + mark + '/editModel', 600, 400);
}

function editProvince(mark){
	var row = $('#tt').datagrid('getSelected');
	var mark = row.mark;
	showMyWindow('模拟器配置| 编辑省份配置', '/channelapk/' + mark + '/provinceUpdate', 850, 500);
}

function editRetent(mark){
	var row = $('#tt').datagrid('getSelected');
	var mark = row.mark;
	showMyWindow('模拟器配置| 编辑留存配置', '/customization/' + mark + '/retentList', 600, 400);
}

$(function(){
	 $('#tt').edatagrid({
       updateUrl: '/channelapk/provinceRateUpdate',
       url: '/channelapk/provinceconfigList?json'
    });
});	
function formatterneedLoginSuccess(value){
	if(value == 0){
		return "代理登录";
	}
	if(value == 1){
		return "需要SDK登录";
	}
	if(value == 2){
		return "咪咕登录";
	}
	if(value == 3){
		return "代理或咪咕登录";
	}
	if(value == 4){
		return "验证码";
	}
}
function formattersmsinterfaceid(value){
	if(value == 0){
		return "音乐";
	}
	if(value == 1){
		return "动漫";
	}
	if(value == 2){
		return "视频";
	}
	if(value == 3){
		return "阅读";
	}
}